package com.d3works.csv.script;

import com.d3works.apps.sale.db.SaleOrderLine;
import com.d3works.apps.sale.service.saleorder.SaleOrderLineService;
import com.d3works.exception.D3worksException;
import com.d3works.inject.Beans;
import java.util.Map;

public class ImportSaleOrderLine {

  public Object importSaleOrderLine(Object bean, Map<String, Object> values)
      throws D3worksException {
    assert bean instanceof SaleOrderLine;

    SaleOrderLine saleOrderLine = (SaleOrderLine) bean;
    SaleOrderLineService saleOrderLineService = Beans.get(SaleOrderLineService.class);
    saleOrderLine.setTaxLine(
        saleOrderLineService.getTaxLine(saleOrderLine.getSaleOrder(), saleOrderLine));
    saleOrderLineService.computeValues(saleOrderLine.getSaleOrder(), saleOrderLine);

    return saleOrderLine;
  }
}
